/**
 * <p>Title: liteflow</p>
 * <p>Description: 轻量级的组件式流程框架</p>
 * @author Bryan.Zhang
 * @email weenyc31@163.com
 * @Date 2020/4/1
 */
package io.mft.flow.core.executable;

import io.mft.commons.function.ExecuteReturn;
import io.mft.flow.core.executable.component.NodeComponent;
import io.mft.flow.data.ChainContext;

public class Node implements Executable {

	private String id;
	private NodeComponent instance;

	public Node(String id, NodeComponent instance) {
		this.id = id;
		this.instance = instance;
	}


	public NodeComponent getInstance() {
		return instance;
	}


	@Override
	public ExecuteReturn execute(ChainContext context) throws Exception {
		try {
			ExecuteReturn executeReturn = instance.execute(context);
			return executeReturn;
		} catch (Exception e) {
			throw e;
		}
	}

	@Override
	public ExecutableType getType() {
		return ExecutableType.NODE;
	}

	@Override
	public String getId() {
		return id;
	}
}
